﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using ZeCloud.Resto55.Business;
using ZeCloud.Resto55.Business.Table;

namespace Resto55Business_WebRole
{
    public partial class TestIndex : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void cmdSearch_Click(object sender, EventArgs e)
        {
            BusinessFacade facade = BusinessFacade.CreerFacade();
            RestoService svc = facade.GetRestoService();
            IEnumerable<Resto> resultats = svc.RechercherRestosParMots(txtSearch.Text);
            foreach (Resto resto in resultats)
            {
                Response.Write(resto.nom + " - " + resto.ville + "<br />");
            }

        }

        protected void cmdRebuildIndex_Click(object sender, EventArgs e)
        {
            DateTime start = DateTime.Now;

            BusinessFacade facade = BusinessFacade.CreerFacade();
            RestoService svc = facade.GetRestoService();
            svc.RebuilRestoIndex();

            TimeSpan span = DateTime.Now.Subtract(start);
            Response.Write(String.Format("Index reconstruit en {0:0}.{1:000}s", span.Hours * 3600 + span.Minutes * 60 + span.Seconds, span.Milliseconds));
        }
    }
}
